/*
 * @Description: IoUtil
 * @Author: zhaokun
 * @Date: 2022-01-07 15:24:21
 * @LastEditTime: 2022-01-15 13:18:05
 * @FilePath: \user\common\nwIo.go
 */
package common

import (
	"io/ioutil"
)

type IoUtil interface {
	FilePutContents(path string, content string)
	FileGetContents(path string) string
}

type nwIoUtil struct {
}

func NewNwIoUtil() *nwIoUtil {
	return &nwIoUtil{}
}

func (ioUtil *nwIoUtil) FilePutContents(path string, content string) error {
	err := ioutil.WriteFile(path, []byte(content), 0666)
	if err != nil {
		return err
	}
	return nil
}

func (ioUtil *nwIoUtil) FileGetContents(path string) (string, error) {
	content, err := ioutil.ReadFile(path)
	if err != nil {
		return "", err
	}
	return string(content), nil
}
